import {QueryDataBean} from '../bean/QueryDataBean';
class TableElementsModel {
  constructor(appId = '', keys = [], tableElements = {}, query = new QueryDataBean()) {
    this.appId = appId;
    this.keys = keys;
    this.tableElements = tableElements;// {key: TableElement}
    this.query = query;
    this.appName = '';
  }
  get appId() {
    return this.appId;
  }
  get appName() {
    return this.appName;
  }
  get keys() {
    return this.keys;
  }
  get tableElements() {
    return this.tableElements;
  }
  get query() {
    return this.query;
  }
  set appId(appId) {
    this.appId = appId;
  }
  set appName(appName) {
    this.appName = appName;
  }
  set keys(keys) {
    this.keys = keys;
  }
  set query(query) {
    this.query = query;
  }
  addElement(tableElement) {
    const elementId = tableElement.elementId;
    this.tableElements[elementId] = tableElement;
  }
  setCustomTableElementValue(count, labelName) {
    Object.keys(this.tableElements).forEach(elementId =>{
      const element = this.tableElements[elementId];
      if (element.isCustomElement) {
        element.resetDataList(count, labelName);
      }
    });
  }
  clearElementDataList() {
    this.tableElements.forEach((tableElement) =>{
      tableElement.elementDataList = [];
    });
  }
  getTableElementIds() {
    const elementsIds = [];
    this.tableElements.forEach(tableElement =>{
      elementsIds.push(tableElement.elementId);
    });
    return elementsIds;
  }
}
export {
  TableElementsModel
};